#include <stdio.h>

/*
    循环队列实现
*/
typedef struct queue
{
    int *items;     // 首元素指针
    int n;          // 元素大小
    int head, tail; // 头尾指针
} CircularQueue;

int enqueue(CircularQueue *queue, int item)
{
    if ((queue->tail + 1) % queue->n == queue->head)
    {
        return 0;
    }
    queue->items[queue->tail] = item;
    queue->tail = (queue->tail + 1) % queue->n;
    return 1;
}

int dequeue(CircularQueue *queue)
{
    if (queue->head == queue->tail)
        return NULL;
    int item = queue->items[queue->head];
    queue->head = (queue->head + 1) % queue->n;
    return item;
}